<template>
    <el-card  shadow="hover" :body-style="{ padding: '20px' }">
        <el-form :inline="true">
            <el-form-item label="一级分类">
                <el-select v-model="CategoryStore.c1Id" @change="c1handler" :disabled="scene!=0">
                    <el-option :label="c1.name" :value="c1.id" v-for="(c1,index) in CategoryStore.c1List"
                        :key="c1.id" />
                </el-select>
            </el-form-item>
            <el-form-item label="二级分类">
                <el-select v-model="CategoryStore.c2Id" @change="c2handler" :disabled="scene!=0">
                    <el-option :value="c2.id" :label="c2.name" v-for="(c2,index) in CategoryStore.c2List"
                        :key="c2.id" />
                </el-select>
            </el-form-item>
            <el-form-item label="三级分类">
                <el-select v-model="CategoryStore.c3Id" :disabled="scene!=0">
                    <el-option :value="c3.id" :label="c3.name" v-for="(c3,index) in CategoryStore.c3List"
                        :key="c3.id" />
                </el-select>
            </el-form-item>
        </el-form>
 </el-card>
</template>

<script setup lang="ts">
    
import { ref, onMounted ,onUnmounted} from 'vue'
import categoryStore from '../../stores/category'
defineProps(['scene'])

// console.log(categoryStore);
let CategoryStore = categoryStore()
// console.log(CategoryStore);

onMounted(() => {
    CategoryStore.getC1List()
})
const c1handler = () => {
    CategoryStore.getC2List()
}
const c2handler = () => {
    CategoryStore.getC3List()
}
onUnmounted(()=>{
    CategoryStore.c1List=[],
    CategoryStore.c2List=[],
    CategoryStore.c3List=[],
    CategoryStore.c1Id='',
    CategoryStore.c2Id='',
    CategoryStore.c3Id=''
})
</script>

<style scoped>

</style>